﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Util;

namespace UI
{
    public partial class Card : System.Web.UI.Page
    {
        public string appid = "";
        public string signature = "";
        public string noncestr = "";
        public long timestamp = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            WeiXin wx = new WeiXin();
            string domain = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_REFERER"];
            Common.Log("domain:"+domain);
            string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
            IDictionary<string, string> resultMap = new Dictionary<string, string>();
            string Act = "Find_WxJsSDKParam";
            string Timestamp = Common.GetTimestamp().ToString();
            resultMap.Add("Act", Act);
            resultMap.Add("Timestamp", Timestamp);
            resultMap.Add("Sign", Common.GetSign(Act, Timestamp));
            resultMap.Add("Url", url);
            string param = Common.joinObjectMapValue(resultMap, '&');
            string json = wx.HttpPost(domain + "/tools/member.ashx", param);
            dynamic dy = wx.ConvertJson(json);
            Common.Log(json);
            Common.Log(url);

            appid = dy.Data.appId;
            noncestr = dy.Data.nonceStr;
            timestamp = dy.Data.timestamp;
            signature = dy.Data.signature;
        }
        
    }
}